import 'dart:async';

import 'package:sonora/models/sj_block_list_item_data.dart';
import 'package:sonora/models/sj_broad_caster_data.dart';
import 'package:sonora/models/sj_broad_caster_response_data.dart';
import 'package:sonora/models/sj_config_data.dart';
import 'package:sonora/models/sj_friend_list_item_data.dart';
import 'package:sonora/models/sj_response_data.dart';
import 'package:sonora/services/sj_api_home_service.dart';
import 'package:sonora/utils/sj_storage_utils.dart';

class SjHomeRepository {
  final SjApiHomeService apiService;
  SjHomeRepository(this.apiService);

  Future<List<SjBroadCasterData>?> getWallSearch() async {
    SjBroadCasterResponseData? responseData =
        await SjStorageUtils.getBroadCasterResponseData();
    if (responseData == null || responseData.data == null || responseData.data!.isEmpty) {
      responseData = await apiService.getWallSearch(20, 1);
      SjStorageUtils.saveBroadCasterResponseData(responseData);
    }
    return responseData.data;
  }

  FutureOr<SjResponseData> addFriend(String followUserId) async {
    return await apiService.addFriend(followUserId);
  }

    FutureOr<SjResponseData> unFriend(String followUserId) async {
    return await apiService.unFriend(followUserId);
  }

  FutureOr<SjResponseData> insertRecord(String? broadcasterId, String? complainCategory, String? complainSub) async {
    return await apiService.insertRecord(broadcasterId, complainCategory, complainSub);
  }

  Future<SjResponseData> validToken() async {
    SjResponseData responseData = await apiService.validToken();
    return responseData;
  }

  Future<SjResponseData> getStrategy() async {
    SjResponseData responseData = await apiService.getStrategy();
    return responseData;
  }

  Future<SjConfigData?> getAppConfig() async {
    return await apiService.getAppConfig();
  }

  Future<SjResponseData> getUserInfo() async {
    return apiService.getUserInfo();
  }

    Future<List<SjBlockListItemData>> blockList() async {
    List<SjBlockListItemData> list = await apiService.blockList();
    return list;
  }

    Future<List<SjFriendListItemData>> friendList() async {
    List<SjFriendListItemData> list = await apiService.friendList();
    return list;
  }
}
